import http from '@/utils/http'

const BASE_URL = '/testing/apiCaseModule'

export interface ApiCaseModuleResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ApiCaseModuleDetailResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ApiCaseModuleQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface ApiCaseModulePageQuery extends ApiCaseModuleQuery, PageQuery {}

/** @desc 查询接口用例模块列表 */
export function listApiCaseModule(query: ApiCaseModulePageQuery) {
  return http.get<PageRes<ApiCaseModuleResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询接口用例模块详情 */
export function getApiCaseModule(id: string) {
  return http.get<ApiCaseModuleDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增接口用例模块 */
export function addApiCaseModule(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改接口用例模块 */
export function updateApiCaseModule(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除接口用例模块 */
export function deleteApiCaseModule(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出接口用例模块 */
export function exportApiCaseModule(query: ApiCaseModuleQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
